package cn.xxstudy.jenkinsdemo2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import cn.xxstudy.mylibrary.Lib
import kotlinx.android.synthetic.main.activity_main.*
import okhttp3.*
import java.io.IOException
import kotlin.concurrent.thread

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val client = OkHttpClient.Builder()
            .build()
        text.setOnClickListener {
            val request = Request.Builder()
                .url("https://xxStudy.cn")
                .build()
            thread(true) {
                val newCall = client.newCall(request)
                val response = newCall.execute()
                runOnUiThread {
                    Toast.makeText(this, "${response.body?.string()}", Toast.LENGTH_SHORT).show()
                }
            }

        }
    }
}